home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16918 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  35 lines

  1. Newsgroups: comp.lang.c++
  2. Path: presby.edu!jtbell
  3. From: jtbell@presby.edu (Jon Bell)
  4. Subject: Re: Reading ENUMS  from FILES
  5. Message-ID: <DprHKo.70C@presby.edu>
  6. Date: Fri, 12 Apr 1996 18:19:36 GMT
  7. References: <316EF715.37D8@mail.soton.ac.uk>
  8. Organization: Presbyterian College, Clinton, South Carolina USA
  9.  
  10.  jcridge  <jcridge@mail.soton.ac.uk> wrote:
  11. >I've not been able to find a way of forcing C++ to read in my own
  12. >enumurated value types from files. I had thought that the SCANF 
  13. >function would be able to cope, but it seems not.  Could anyone help me 
  14. >out here ?
  15.  
  16. Standard C++ doesn't allow you to read enum values directly.  You have to 
  17. overload the >> operator with a function that reads characters and parses 
  18. them to determine which enum value is being input.
  19.  
  20. >Also, I'm used to PASCAL which made alot of things like this rather 
  21. >easy, 
  22.  
  23. The Pascals I've worked with don't allow you to input enumerated types 
  24. directly, either... you must have been lucky!  :-)
  25.  
  26. >including reading whole user defined RECORD structures
  27. >with mixed types, is this possible in C++ ?
  28.  
  29. Yes, C++ has these.  They're called "structs" and "classes".  They can 
  30. contain not only data, but also functions.
  31.  
  32. -- 
  33. Jon Bell <jtbell@presby.edu>                        Presbyterian College
  34. Dept. of Physics and Computer Science        Clinton, South Carolina USA
  35.